<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
      

        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="活动名称">
          {{model.EventTitle}}
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="姓名">
          {{model.UserName}}
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="公司">
          {{model.CompanyName}}
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="职位">
          {{model.Job}}
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="电话">
          {{model.Phone}}
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="邮箱">
          {{model.Email}}
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="微信">
          {{model.Wechat}}
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="认证状态">
          {{model.UserInfo_IdentificationStatus_Value && model.UserInfo_IdentificationStatus_Value.split('-').length > 1?model.UserInfo_IdentificationStatus_Value.split('-')[1]:''}}
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="是否通过">
          <a-radio-group name="radioGroup" @change="changePass" v-decorator="['isPass']" :default-value="1">
            <a-radio :value="1">
              通过
            </a-radio>
            <a-radio :value="2">
              不通过
            </a-radio>
          </a-radio-group>
        </a-form-item>
        <a-form-item
          v-if="model.isPass == 2"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="不通过原因">
          <a-input type="textarea" v-decorator="['ApproveRemark',{rules:[{required:true,message:'请填写'}]}]"/>
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
  import { httpAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import moment from "moment"

  export default {
    name: "AuthUserModal",
    data () {
      return {
        UserRoleData:[],
        workStatusData:[],
        title:"操作",
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        form: this.$form.createForm(this),
        url: {
          add: "/user/add",
          edit: "/user/update",
          baseList:"/baseInfo/queryRows",
        },
      }
    },
    created () {
    },
    methods: {
      changePass(val){
        this.model.isPass = val.target.value;
        this.$forceUpdate();
      },
      add () {
        this.edit({});
      },
      edit (record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.model.isPass = 1;
        this.visible = true;
        

      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = 'post';
            if(values.isPass != 2){
              httpurl+='/userEvent/approvePassed';
            }else{
              httpurl+='/userEvent/approveFailed';
            }
            let formData = Object.assign(this.model, values);
            let param = {
              UserEventId:formData.UserEventId,
              ApproveRemark:formData.ApproveRemark
            }
            this.$http.postAction(httpurl,param,method).then((res)=>{
              if(res.status == 1){
                that.close();
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              // that.close();
            })



          }
        })
      },
      handleCancel () {
        this.close()
      },


    }
  }
</script>

<style lang="less" scoped>

</style>